package com.example.demo.service.impl;

import com.example.demo.entity.Book;
import com.example.demo.mapper.BookMapper;
import com.example.demo.service.BookService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BookServiceImpl implements BookService {

    @Resource
    private BookMapper bookMapper;

    @Override
    public int insert(Book book) {
        return bookMapper.insert(book);
    }

    @Override
    public int updateById(Book book) {
        return bookMapper.updateById(book);
    }

    @Override
    public int deleteById(Long id) {
        return bookMapper.deleteById(id);
    }

    @Override
    public int deleteBatchIds(List<Integer> ids) {
        return bookMapper.deleteBatchIds(ids);
    }

    @Override
    public List<Book> selectPage(int pageNum, int pageSize, String search1, String search2, String search3) {
        int offset = (pageNum - 1) * pageSize;
        return bookMapper.selectPage(offset, pageSize, search1, search2, search3);
    }

    @Override
    public int selectCount(String search1, String search2, String search3) {
        return bookMapper.selectCount(search1, search2, search3);
    }
}